apache的proxy代理总访问后端web的第一个虚拟主机

        问题,如题。怎么折腾都是一直访问第一个虚拟主机,后来找到问题所在。是我配置的不对。错误配置是这样的:

1
2
3
4
5
6
7
8
9
ServerName www.test.com
CustomLog "/dev/null" combined
ProxyRequests Off
Order deny,allow
Allow from all
ProxyPass / http://192.168.13.111/
ProxyPassReverse / 192.168.13.111/

        问题出在了: ProxyPass / http://192.168.13.111/

        要改成这样: ProxyPass / http://www.test.com/

        所以正确的配置是这样的:

1
2
3
4
5
6
7
8
9
ServerName www.test.com
CustomLog "/dev/null" combined
ProxyRequests Off
Order deny,allow
Allow from all
ProxyPass / http://www.test.com/
ProxyPassReverse / 192.168.13.111/

        另外需要注意的是,需要在/etc/hosts 中加一条记录

1
192.168.13.111 www.test.com